/**
 * Created by Administrator on 2018/12/13.
 */
function bxExcelImport($scope, $route, CertusFormAjax, CertusJsonAjax, $location, $http, $cookies){

    $scope.importExcel = function(){

        $scope.bxType = null;
        $("#fileUploadId").val("");
        //打开 上传页面
        $(".hidefile").show();
    }



    $scope.bxExcelImport = function(){
        if($scope.bxType && !angular.isUndefined($scope.bxType)){
            var form = new FormData();
            var file = document.getElementById("fileUploadId").files[0];
            form.append('file', file);
            form.append("bxType", $scope.bxType);
            var tish = layer.load(1);
            CertusFormAjax.upload("bxExcelImport", form, function(res){
                layer.close(tish);
                if(res.data == "success"){
                    layer.msg("数据导入成功");
                    $(".hidefile").hide();
                }

                layer.msg(res.data);
                dataInit.refresh(true);
            });
        }

    }

    $scope.bxSelect = [
        {name:"招待报销",code:"ZDBX"},
        {name:"现金报销",code:"XJBX"},
        {name:"差旅报销",code:"CLBX"}
    ]
    //查询 后台 失败 数据库 表
    CertusJsonAjax.dataInit("errorLogList",null,smgProColumns,'logTimerDis','logTimerDisContainer');


}

function cgdExcelImport($scope, $route, CertusFormAjax, CertusJsonAjax, $location, $http, $cookies){

    $scope.importExcel = function(){

        $scope.bxType = "CGD";
        $("#fileUploadId").val("");
        //打开 上传页面
        $(".hidefile").show();
    }

    $scope.bxExcelImport = function(){
        if($scope.bxType && !angular.isUndefined($scope.bxType)){
            var form = new FormData();
            var file = document.getElementById("fileUploadId").files[0];
            form.append('file', file);
            form.append("bxType", $scope.bxType);
            var tish = layer.load(1);
            CertusFormAjax.upload("bxExcelImport", form, function(res){
                layer.close(tish);
                if(res.data == "success"){
                    layer.msg("数据导入成功");
                    $(".hidefile").hide();
                }

                layer.msg(res.data);
            });
        }

    }

    $scope.bxSelect = [
        {name:"采购单导入",code:"CGD"}
    ]
    //查询 后台 失败 数据库 表
    CertusJsonAjax.dataInit("cgdErrorLogList",null,smgProColumns,'cgdlogTimerDis','cgdlogTimerDisContainer');


}


var smgProColumns = [{
    id: 'userName',
    title: '提交人',
    type: 'string',
    width: 75,
    columnClass: 'text-center',
    // width:150
},{
    id: 'content',
    title: '提交时间',
    type: 'string',
    width: 150,
    columnClass: 'text-center',
    resolution:function (value, record, column, grid, dataNo, columnNo){
        var date = new Date(record.createTime);
        var content = $.fn.dlshouwen.grid.tools.dateFormat(date, "yyyy-MM-dd hh:mm");
        return content;
    }
}, {
    id: 'user_name',
    title: '单号',
    type: 'string',
    columnClass: 'text-center',
    // width:70
}
];


function wechatDatagrid($scope, $route, CertusFormAjax, CertusJsonAjax, $location, $http, $cookies){
    var dataInit = CertusJsonAjax.dataInit("wechatList",null,wechatUserColumns,'wechatDataId','wechatDataController');

    $$scope = $scope;

    $$scope.search = {};

    $scope.searchCP = function(){
        dataInit.parameters = $scope.search;
        dataInit.refresh(true);
    }


}

var wechatUserColumns = [{
    id: 'userName',
    title: '姓名',
    type: 'string',
    columnClass: 'text-center',
    width:75
},{
    id: 'createTime',
    title: '提交时间',
    type: 'string',
    width: 150,
    columnClass: 'text-center',
    resolution:function (value, record, column, grid, dataNo, columnNo){
        if(record.createTime){
            var date = new Date(record.createTime);
            var content = $.fn.dlshouwen.grid.tools.dateFormat(date, "yyyy-MM-dd hh:mm");
            return content;
        }
        if(record.date){
            var date = new Date(record.date);
            var content = $.fn.dlshouwen.grid.tools.dateFormat(date, "yyyy-MM-dd hh:mm");
            return content;
        }
    }
},{
    id: 'content',
    title: '内容',
    type: 'string',
    columnClass: 'text-left',
    // width:150
}
];

function mailDatagrid($scope, $route, CertusFormAjax, CertusJsonAjax, $location, $http, $cookies){
    var dataInit2 = CertusJsonAjax.dataInit("mailList",null,wechatUserColumns,'mailDataId','mailDataController');

    $$scope = $scope;

    $$scope.search = {};

    $scope.searchCP = function(){
        dataInit2.parameters = $scope.search;
        dataInit2.refresh(true);
    }

}